package com.example.myapp.chat;

public class MsgReceiveThread implements Runnable {

    private ChatMessage chatMessage;

    public MsgReceiveThread(ChatMessage onMessage) {
        this.chatMessage = onMessage;
    }

    @Override
    public void run() {
          while(true){
              try {
                  Thread.sleep(1 * 500);
                  String msg = ChatManager.getInstance().getMsg();
                  if(msg!=null && !msg.equals("")){
                      if(chatMessage !=null)
                         chatMessage.onReceivedSuccess(msg);
                  }
              } catch (InterruptedException e) {
                  e.printStackTrace();
                  chatMessage.onReceivedFailure(e);
              }
          }
    }

}
